<template>
  <div class="userinfo">
    <ul v-if="identity==='学生'">
      <li>学号：{{ userinfo.id }}</li>
      <li>姓名：{{ userinfo.name }}</li>
      <li>性别：{{ userinfo.sex }}</li>
      <li>学院：{{ userinfo.school }}</li>
      <li>专业：{{ userinfo.major }}</li>
      <li>班级：{{ userinfo.classid }}</li>
    </ul>
    <ul v-if="identity==='教师'">
      <li>学号：{{ userinfo.id }}</li>
      <li>姓名：{{ userinfo.name }}</li>
      <li>性别：{{ userinfo.sex }}</li>
      <li>学院：{{ userinfo.school }}</li>
      <li>系别：{{ userinfo.department }}</li>
    </ul>
    <ul v-if="identity==='管理员'">
      <li>学号：{{ userinfo.id }}</li>
      <li>姓名：{{ userinfo.name }}</li>
      <li>性别：{{ userinfo.sex }}</li>
      <li>学院：{{ userinfo.school }}</li>
    </ul>
  </div>
</template>

<script>
import { getUserInfo } from '@/api/user';
export default {
  data(){
    return{
      userinfo:{
        id:'',
        name:'',
        sex:'',
        school:'',
        department:'',
        major:'',
        classid:''
      },
      identity:localStorage.getItem('identity')
    }
  },
  mounted(){
    this.$nextTick(()=>{
      getUserInfo().then(res=>{
        this.userinfo={...res.data.data}
        console.log(res);
        
      })
    })
  }
}
</script>

<style scoped>
.userinfo{
  margin-top: 8px;
  margin-left: 10px;
  line-height: 28px;
}
</style>